<?php
class C_Work extends MVC_Controller_Acp {

    public function index () {
        $this->_addView('Work_List');
    }


    public function diag () {
        header("Content-type: image/svg+xml");

        $color = array();
        $color[] = 'color data array';
        $color[] = '#53EC3B';
        $color[] = '#FFDB73';
        $color[] = '#33CCFF';
        $color[] = '#7F74DD';
        $color[] = '#E969B1';
        $color[] = '#FE7276';
        $color[] = '#FFFFFF';

        $arAllSteps = $this->_getModel('Work')->getAllSteps();
        $arStepsColors = $this->_getModel('Work')->getStepsColors();

        $this->_addView('Work_Diag')
             ->_addVariable('color', $arStepsColors)
             ->_addVariable('steps', $arAllSteps);
    }


    public function legend () {
        $arLegend = $this->_getModel('Work')->getLegend();
         $arAllSteps = $this->_getModel('Work')->getAllSteps();

        $this->_addView('Work_Legend')
             ->_addVariable('legend', $arLegend)
             ->_addVariable('steps', $arAllSteps);

    }


    public function _postLegend () {
        if ($this->_POST()->isExists('is_ok')) {
            $this->_getModel('Work')->setStepOk($this->_POST_Item('step_id'));
        } elseif ($this->_POST()->isExists('in_work')) {
            $this->_getModel('Work')->setStepWork($this->_POST_Item('step_id'));
        }

       $this->legend();
    }

}